/*
 * Copyright (c) 2009, Jan Pastor. All Rights Reserved.
 */

package sk.jp.jitag.ui.thumb;

import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.image.BufferedImage;

import sk.jp.jitag.vo.file.JpegImageFile;

/**
 * Jpeg image thumbnail.
 */
public class JpegImageThumbnail extends FileThumbnail {

    public JpegImageThumbnail(JpegImageFile mediaFile, int thumbnailSize) {
        super(mediaFile, thumbnailSize);
    }

    //----------------------------------------------------------------------


    //----------------------------------------------------------------------

    @Override
    protected void paintThumbnailContent(Graphics2D g2d) {
        JpegImageFile mediaFile = (JpegImageFile)getMediaFile();
        BufferedImage thumbnail = mediaFile.getThumbnail(new Dimension(getThumbnailSize(), getThumbnailSize()));

        Point thumbnailLocation = countThumbnailRealLocation(
                        new Dimension(thumbnail.getWidth(), thumbnail.getHeight()));

        g2d.drawImage(thumbnail, thumbnailLocation.x, thumbnailLocation.y, null);
    }

}
